// pages/tools/counter/counter.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    count: 0,
    reset_status: 0,
    bottom_text: "重置\n（小心按错导致惨案）",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function () {
    this.setData({
      count: 0,
      reset_status: 0,
      bottom_text: "重置\n（小心按错导致惨案）",
    });
  },
  onShareAppMessage: function (res) {
    return {
      title: '快来看看学长开发的万能基物实验小程序！',
      path: 'pages/index/index',
      imageUrl: 'https://s1.ax1x.com/2020/07/25/aSICY4.jpg',
      success: function (res) {
        console.log('成功分享', res)
      }
    }
  },

  voidFunc: function() {
    // doing nothing
  },

  addToCount: function() {
    this.setData({
      count: this.data.count + 1,
      reset_status: 0,
      bottom_text: "重置\n（小心按错导致惨案）",
    })
  },

  reset: function() {
    if (this.data.reset_status == 0) {
      this.setData({
        reset_status: 1,
        bottom_text: "你确定要重置吗？\n如果不是请继续正常计数"
      })
    } else {
      this.setData({
        count: 0,
        reset_status: 0,
        bottom_text: "重置\n（小心按错导致惨案）",
      })
    }
  },
})